In a nonvolatile memory such as a NAND flash memory (hereinafter, referred to as a NAND memory), user data to be written are scrambled into a random sequence and then written into a memory cell in order to improve reliability of the data when the data are read from a memory cell. At this point, if randomness of a random sequence is not sufficient, an error rate at the time of reading data may be increased.